package com.atguigu.gulimall.seckill.config;

import com.atguigu.gulimall.seckill.service.UpSeckillScheduleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

@Configuration
@EnableScheduling   // 开启定时任务
@EnableAsync        // 做定时任务 需要开启异步  防止出现 调度任务 阻塞
public class ScheduledConfig {

    @Autowired
    UpSeckillScheduleService upSeckillScheduleService;

    @Scheduled(cron = "0 0 3 * * ?")  //表示每天晚上凌晨3点
    @Async
    public void scheduledUpSeckill(){
      upSeckillScheduleService.upSeckillRecentThreeDay();
    }




}
